import request from '../index';
import fileDownload from 'js-file-download';

const baseUrl = '/base-server';
const financeUrl = '/finance-server';

//电站导出
export const EXPORT_STATION = `${baseUrl}/station/exportStation`;

//电桩导出
export const EXPORT_EQUIPMENT = `${baseUrl}/equipment/exportByPageQueryEquipment`;

// 充电卡导出
export const EXPORT_CHARGECARD = `${baseUrl}/charge/exportChargeCard`;

// 查询充电卡信息列表
export const URL_QUERYCHARGECARDLIST = `${baseUrl}/charge/queryChargeCardList`;
export const querychargeCardList = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/charge/queryChargeCardList`,
    params: { form: params, pages: pages },
  });
};

// 查询充电卡信息列表
export const URL_EMPSTOREIMPORT = `${baseUrl}/charge/empStoreImport`;
export const empStoreImport = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/charge/empStoreImport`,
    params: { form: params, pages: pages },
  });
};

// 充电卡下拉数据
export const queryAllChargeCard = (params: any) => {
  return request({
    url: `${baseUrl}/charge/queryAllChargeCard`,
    params: { form: params },
  });
};

// 充电卡修改
export const updateChargeCard = (params: any) => {
  return request({
    url: `${baseUrl}/charge/updateChargeCard`,
    params: { form: params, successMsg: '1' },
  });
};

// 充电卡作废、恢复
export const canCelChargeCard = (params: any) => {
  return request({
    url: `${baseUrl}/charge/canCelChargeCard`,
    params: { form: params },
  });
};

//-------------------------------------------------

// 分页查询计费模板管理
export const URL_PAGEQUERYCOSTTEMPLATE = `${baseUrl}/station/pageQueryCostTemplate`;
export const pageQueryCostTemplate = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/station/pageQueryCostTemplate`,
    params: { form: params, pages: pages },
  });
};

//删除价格模板
export const delCostTemplate = (params: any) => {
  return request({
    url: `${baseUrl}/station/delCostTemplate`,
    params: { form: params, successMsg: '2' },
  });
};

//添加价格模板
export const addCostTemplate = (params: any) => {
  return request({
    url: `${baseUrl}/station/addCostTemplate`,
    params: { form: params, successMsg: '1' },
  });
};

//查询价格模板
export const queryCostTemplate = (params: any) => {
  return request({
    url: `${baseUrl}/station/queryCostTemplate`,
    params: { form: params },
  });
};

//修改价格模板
export const updateCostTemplate = (params: any) => {
  return request({
    url: `${baseUrl}/station/updateCostTemplate`,
    params: { form: params, successMsg: '1' },
  });
};

//根据协议版本查询计费模板
export const queryCostTemplateByProtocolVersion = (params: any) => {
  return request({
    url: `${baseUrl}/station/queryCostTemplateByProtocolVersion`,
    params: { form: params },
  });
};

// 应用电桩2-电枪分页列表
export const URL_QUERYCOSTTEMPLATEEQUIPMENT = `${baseUrl}/station/queryCostTemplateEquipment`;
export const queryCostTemplateEquipment = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/station/queryCostTemplateEquipment`,
    params: { form: params, pages: pages },
  });
};
//-------------------------------------------------
//根据归属电站运营商查询可选分润方 -- 后面要挪到财务
export const queryByOrgId = (params: any) => {
  return request({
    url: `${financeUrl}/shareProfit/queryByOrgId`,
    params: { form: params },
  });
};

// 分页查询站点列表
export const URL_PAGEQUERYSTATION = `${baseUrl}/station/pageQueryStation`;
export const pageQueryStation = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/station/pageQueryStation`,
    params: { form: params, pages: pages },
  });
};

//启动站点前置查询是否有电桩
export const checkEquipmentByStationId = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/checkEquipmentByStationId`,
    params: { form: params },
  });
};

//启动站点
export const startStation = (params: any) => {
  return request({
    url: `${baseUrl}/station/startStation`,
    params: { form: params, successMsg: '2' },
  });
};
//停止站点
export const stopStation = (params: any) => {
  return request({
    url: `${baseUrl}/station/stopStation`,
    params: { form: params, successMsg: '2' },
  });
};
//删除站点
export const delStation = (params: any) => {
  return request({
    url: `${baseUrl}/station/delStation`,
    params: { form: params, successMsg: '2' },
  });
};

//添加站点
export const addStation = (params: any) => {
	  console.log()
  return request({
    url: `${baseUrl}/station/addStation`,
    params: { form: params },
  });
};

//修改站点
export const updateStation = (params: any) => {
  return request({
    url: `${baseUrl}/station/updateStation`,
    params: { form: params, successMsg: '1' },
  });
};

//查询站点详情
export const queryStationDetail = (params: any) => {
  return request({
    url: `${baseUrl}/station/queryStationDetail`,
    params: { form: params },
  });
};
//查询站点详情-电枪分页列表
export const URL_PAGEQUERYCONNECTORBYSTATIONID = `${baseUrl}/equipment/pageQueryConnectorByStationId`;
export const pageQueryConnectorByStationId = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/equipment/pageQueryConnectorByStationId`,
    params: { form: params, pages: pages },
  });
};

//查询站点
export const queryAllStation = (params: any) => {
  return request({
    url: `${baseUrl}/station/queryAllStation`,
    params: { form: params },
  });
};

//根据电站id 和协议id 判断该模板在站点是否存在
export const queryByStationIdAndProtocolVersionId = (params: any) => {
  return request({
    url: `${baseUrl}/station/queryByStationIdAndProtocolVersionId`,
    params: { form: params },
  });
};

//-------------------------------------------------
// 查询电桩的品牌型号树形结构
export const equipmentBrandAndModelTreeData = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/equipmentBrandAndModelTreeData`,
    params: { form: params },
  });
};
// 分页查询电桩
export const pageQueryEquipment = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/equipment/pageQueryEquipment`,
    params: { form: params, pages: pages },
  });
};

//查询已有电桩功率
export const queryAllEquipmentModelPower = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/queryAllEquipmentModelPower`,
    params: { form: params },
  });
};

// 电桩导入
export const URL_EQUIPMENTIMPORT = `${baseUrl}/equipment/equipmentImport`;
export const userImport = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/equipmentImport`,
    params: { form: params },
  });
};

// 电桩code导出
export const getQRCode = (params: any) => {
  request({
    url: `${baseUrl}/equipment/connectorCodeExport`,
    responseType: 'blob',
    params: { form: params, export: true },
  }).then((res: any) => {
    fileDownload(res, 'qcode.zip');
  });
};

// 启动电枪
export const startConnector = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/startConnector`,
    params: { form: params, successMsg: '2' },
  });
};

// 停止电枪
export const stopConnector = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/stopConnector`,
    params: { form: params, successMsg: '2' },
  });
};

// 电桩批量校价/ 单个校价
export const batchCheckPrices = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/batchCheckPrices`,
    params: { form: params },
  });
};

// 电桩批量校时/ 单个校时
export const batchCheckTime = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/batchCheckTime`,
    params: { form: params },
  });
};

// 电桩远程重启
export const remoteRestart = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/remoteRestart`,
    params: { form: params },
  });
};

// 所有电桩远程重启(电站下所有电桩)
export const allRemoteRestart = (params: any) => {
  return request({
    url: `${baseUrl}/station/remoteStation`,
    params: { form: params },
  });
};

// 电桩远程升级-版本数据
export const getChargingPileType = (params: any) => {
  return request({
    url: `${baseUrl}/ftp/getChargingPileType`,
    params: { form: params },
  });
};
// 电桩版本号查询
export const paramQuery = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/paramQuery`,
    params: { form: params },
  });
};
// 获取电桩版本号查询
export const getParam = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/getParam`,
    params: { form: params },
  });
};
// 电桩参数值查询
export const getTranslate = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/getTranslate`,
    params: { form: params },
  });
};
// 电桩参数值配置
export const paramTranslate = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/paramTranslate`,
    params: { form: params },
  });
};
// 电桩远程升级
export const remoteUpdate = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/remoteUpdate`,
    params: { form: params },
  });
};
// 电桩批量升级
export const remoteUpdateBath = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/remoteUpdateBath`,
    params: { form: params },
  });
};

// 新增修改电站省监管对接
export const saveOrUpdateStationProvinceRegulator = (params: any) => {
  return request({
    url: `${baseUrl}/station/saveOrUpdateStationProvinceRegulator`,
    params: { form: params, successMsg: '1' },
  });
};

// 查询电站省监管对接
export const queryStationProvinceRegulator = (params: any) => {
  return request({
    url: `${baseUrl}/station/queryStationProvinceRegulator`,
    params: { form: params },
  });
};

// 电站省监管对接是否存在相同充电站省备案号
export const querySameStationProvinceRegulator = (params: any) => {
  return request({
    url: `${baseUrl}/station/querySameStationProvinceRegulator`,
    params: { form: params },
  });
};

//删除电桩
export const delEquipment = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/delEquipment`,
    params: { form: params, successMsg: '2' },
  });
};

// 查询电桩下面的终端的快捷码
export const queryShortCodeByEquipmentId = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/queryShortCodeByEquipmentId`,
    params: { form: params },
  });
};

// 修改电桩下面的终端的快捷码
export const updateShortCodeByEquipmentId = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/updateShortCodeByEquipmentId`,
    params: { form: params, successMsg: '修改成功！' },
  });
};

//添加电桩
export const addEquipment = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/addEquipment`,
    params: { form: params, successMsg: '1' },
  });
};

//批量添加电桩
export const addEquipmentBatch = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/addEquipmentBatch`,
    params: { form: params, successMsg: '1' },
  });
};

//更新电桩
export const updateEquipment = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/updateEquipment`,
    params: { form: params, successMsg: '1' },
  });
};

//查询电桩
export const queryEquipment = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/queryEquipment`,
    params: { form: params },
  });
};

//查询电枪
export const queryConnector = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/queryConnector`,
    params: { form: params },
  });
};

//-------------------------------------------------
// 分页查询站点定时调价
export const URL_PAGEQUERYSTATIONTASKTRANSFERPRICE = `${baseUrl}/equipment/pageQueryStationTaskTransferPrice`;
export const pageQueryStationTaskTransferPrice = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/equipment/pageQueryStationTaskTransferPrice`,
    params: { form: params, pages: pages },
  });
};

//删除站点定时调价
export const delStationTaskTransferPrice = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/delStationTaskTransferPrice`,
    params: { form: params, successMsg: '2' },
  });
};

//新增站点定时调价
export const addStationTaskTransferPrice = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/addStationTaskTransferPrice`,
    params: { form: params, successMsg: '1' },
  });
};

//修改站点定时调价
export const updateStationTaskTransferPrice = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/updateStationTaskTransferPrice`,
    params: { form: params, successMsg: '1' },
  });
};

//查询站点定时调价
export const queryStationTaskTransferPrice = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/queryStationTaskTransferPrice`,
    params: { form: params },
  });
};

// 查询站点定时调价2-结果
export const URL_QUERYRESULTBYSTATIONTASK = `${baseUrl}/equipment/queryResultByStationTaskTransferPriceId`;
export const queryResultByStationTask = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/equipment/queryResultByStationTaskTransferPriceId`,
    params: { form: params, pages: pages },
  });
};

//-------------------------------------------------
// 分页查询电站白名单
export const URL_PAGINGWHITELIST = `${baseUrl}/whiteList/pagingWhiteList`;
export const pagingWhiteList = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/whiteList/pagingWhiteList`,
    params: { form: params, pages: pages },
  });
};

//删除白名单
export const deleteWhite = (params: any) => {
  return request({
    url: `${baseUrl}/whiteList/delete`,
    params: { form: params, successMsg: '2' },
  });
};

//保存白名单
export const addWhiteList = (params: any) => {
  return request({
    url: `${baseUrl}/whiteList/addWhiteList`,
    params: { form: params, successMsg: '1' },
  });
};

//修改白名单
export const updateWhiteList = (params: any) => {
  return request({
    url: `${baseUrl}/whiteList/updateWhiteList`,
    params: { form: params, successMsg: '1' },
  });
};

//白名单详情
export const getWhiteList = (params: any) => {
  return request({
    url: `${baseUrl}/whiteList/getWhiteList`,
    params: { form: params },
  });
};

//-------------------------------------------------
// 分页查询台区
export const URL_PAGINGQUERYPLATFORMAREA = `${baseUrl}/platformArea/pageQueryPlatformArea`;
export const pageQueryPlatformArea = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/platformArea/pageQueryPlatformArea`,
    params: { form: params, pages: pages },
  });
};

// 删除台区前置判断是否存在关联电桩
export const afterDelPlatformAreaById = (params: any) => {
  return request({
    url: `${baseUrl}/platformArea/afterDelPlatformAreaById`,
    params: { form: params },
  });
};

// 删除台区
export const delPlatformAreaById = (params: any) => {
  return request({
    url: `${baseUrl}/platformArea/delPlatformAreaById`,
    params: { form: params, successMsg: '2' },
  });
};

// 新增台区
export const savePlatformArea = (params: any) => {
  return request({
    url: `${baseUrl}/platformArea/savePlatformArea`,
    params: { form: params, successMsg: '1' },
  });
};

// 修改台区
export const updatePlatformArea = (params: any) => {
  return request({
    url: `${baseUrl}/platformArea/updatePlatformArea`,
    params: { form: params, successMsg: '1' },
  });
};

// 根据id查询台区
export const getPlatformAreaById = (params: any) => {
  return request({
    url: `${baseUrl}/platformArea/getPlatformAreaById`,
    params: { form: params },
  });
};

// 校验台区编码是否存在
export const checkIsExistsCodeByChanelId = (params: any) => {
  return request({
    url: `${baseUrl}/platformArea/checkIsExistsCodeByChanelId`,
    params: { form: params },
  });
};

// 台区id查询关联电桩
export const URL_PAGINGQUERYPLATFORMAREAID = `${baseUrl}/platformArea/queryEquipmentByPlatformAreaId`;
export const queryEquipmentByPlatformAreaId = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/platformArea/queryEquipmentByPlatformAreaId`,
    params: { form: params, pages: pages },
  });
};

//台区id查询关联电桩导出
export const EXPORT_PAGINGQUERYPLATFORMAREAID = `${baseUrl}/platformArea/queryEquipmentByPlatformAreaIdExport`;

//-------------------------------------------------
// 分页查询站点评论
export const URL_PAGEQUERYSTATIONCOMMENT = `${baseUrl}/station/pageQueryStationComment`;
export const pageQueryStationComment = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/station/pageQueryStationComment`,
    params: { form: params, pages: pages },
  });
};

//修改站点评论--回复、审核评论
export const updateStationComment = (params: any) => {
  return request({
    url: `${baseUrl}/station/updateStationComment`,
    params: { form: params, successMsg: '2' },
  });
};

//---------------------------------------------------------
// 分页查询互联互通电站
export const URL_PAGEQUERYCECSTATION = `${baseUrl}/station/pageQueryCecStation`;
export const pageQueryCecStation = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/station/pageQueryCecStation`,
    params: { form: params, pages: pages },
  });
};

//互联互通启动站点
export const startCecStation = (params: any) => {
  return request({
    url: `${baseUrl}/station/startCecStation`,
    params: { form: params, successMsg: '2' },
  });
};
//互联互通停止站点
export const stopCecStation = (params: any) => {
  return request({
    url: `${baseUrl}/station/stopCecStation`,
    params: { form: params, successMsg: '2' },
  });
};

// 查询互联互通电站详情
export const queryCecStationDetail = (params: any) => {
  return request({
    url: `${baseUrl}/station/queryCecStationDetail`,
    params: { form: params },
  });
};

// 分页查询互联互通电站
export const URL_PAGEQUERYCECCONNECTORBYSTATIONID = `${baseUrl}/equipment/pageQueryCecConnectorByStationId`;
export const pageQueryCecConnectorByStationId = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/equipment/pageQueryCecConnectorByStationId`,
    params: { form: params, pages: pages },
  });
};


// 周边设备
// 分页查询周边设备
export const pageQueryPeripheral = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/peripheral/pageQueryPeripheral`,
    params: { form: params, pages: pages },
  });
};

// 新增周边设备 /peripheral/addPeripheral
export const addPeripheral = (params: any) => {
  return request({
    url: `${baseUrl}/peripheral/addPeripheral`,
    params: { form: params },
  });
};

// 修改周边设备
export const updPeripheral = (params: any) => {
  return request({
    url: `${baseUrl}/peripheral/updPeripheral`,
    params: { form: params },
  });
};

// 删除周边设备
export const delPeripheral = (params: any) => {
  return request({
    url: `${baseUrl}/peripheral/delPeripheral`,
    params: { form: params },
  });
};

// 查询周边设备详情
export const queryPeripheral = (params: any) => {
  return request({
    url: `${baseUrl}/peripheral/queryPeripheral`,
    params: { form: params },
  });
};

// 通过电站id查询电站设备
export const queryPeripheralList = (params: any) => {
  return request({
    url: `${baseUrl}/peripheral/queryPeripheralList`,
    params: { form: params },
  });
};

// 查询设备追后一帧数据
export const selectDeviceRealTimeData = (params: any) => {
  return request({
    url: `${baseUrl}/peripheral/deviceRealTimeData/selectDeviceRealTimeData`,
    params: { form: params },
  });
};

// 大屏查询电站
export const pageQueryRealTimeConnectorByStationId = (params: any, pages: any) => {
  return request({
    url: `${baseUrl}/equipment/pageQueryRealTimeConnectorByStationId`,
    params: { form: params, pages: pages, isLoading: false },
  });
};

// 批量跟新版本信息
export const paramQueryBatch = (params: any) => {
  return request({
    url: `${baseUrl}/equipment/paramQueryBatch`,
    // params: { masterControl:'82' },
    params: { form: params},
  });
};